package com.software.graduationproject.commons.select;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.metadata.Page;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.ArrayList;
import java.util.List;

public class Pageable<T> implements Page<T> {
    @TableField(
        exist = false
    )
    protected long no = 1L;
    @TableField(
        exist = false
    )
    protected long size = 20L;
    @TableField(
        exist = false
    )
    protected long total;
    @TableField(
        exist = false
    )
    protected List<T> data = new ArrayList();
    @TableField(
        exist = false
    )
    protected List<OrderItem> orders = new ArrayList();
    @TableField(
        exist = false
    )
    protected boolean isSearchPage = true;

    public Pageable() {
    }

    public List<OrderItem> orders() {
        return this.orders;
    }

    public List<T> getData() {
        return this.data;
    }

    public Page setData(List<T> list) {
        this.data = list;
        return this;
    }

    public long getTotal() {
        return this.total;
    }

    public Page setTotal(long total) {
        this.total = total;
        return this;
    }

    public long getSize() {
        return this.size;
    }

    public Page setSize(long size) {
        this.size = size;
        return this;
    }

    public long getNo() {
        return this.no;
    }

    public Page setNo(long no) {
        this.no = no;
        return this;
    }

    @JsonIgnore
    public long getTotalPages() {
        return this.total;
    }

    @JsonIgnore
    public boolean getIsSearchCount() {
        return this.size > 0L;
    }

    public void setIsSearchPage(boolean isSearchPage) {
        this.isSearchPage = isSearchPage;
    }

    @JsonIgnore
    public boolean getIsSearchPage() {
        return this.isSearchPage;
    }
}
